package com.qk.management.controller;

import com.qk.common.Result;
import com.qk.dto.clue.ClueDTO;
import com.qk.dto.clue.ClueSelectPoolByPageDTO;
import com.qk.dto.clue.ClueToFalsyDTO;
import com.qk.dto.clue.ClueUpdateDTO;
import com.qk.entity.Clue;
import com.qk.management.service.ClueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 *  @author SHCJ
 *  @created 2025/10/13 20:26
 *  @description
 */
@RestController
@RequestMapping("/clues")
public class ClueController {
    @Autowired
    private ClueService clueService;

//    新增线索
    @PostMapping
    public Result addClue(@RequestBody ClueDTO clueDTO){
        clueService.addClue(clueDTO);
        return Result.success();
    }

//    分页查询
    @GetMapping
    public Result selectByPage(ClueDTO clueDTO){
        return Result.success(clueService.selectByPage(clueDTO));
    }


//    线索跟进
    @PutMapping("/assign/{clueId}/{userId}")
    public Result updateClue(@PathVariable Integer clueId, @PathVariable Integer userId){
        clueService.updateClueById(clueId, userId);
        return Result.success();
    }

//    根据id查询
    @GetMapping("/{id}")
    public Result selectClueById(@PathVariable Integer id){
        return Result.success(clueService.selectClueById(id));
    }

//    更新
    @PutMapping
    public Result updateClue(@RequestBody ClueUpdateDTO clueUpdateDTO){
        clueService.updateClue(clueUpdateDTO);
        return Result.success();

    }

//    转商机
    @PutMapping("/toBusiness/{id}")
    public Result clueToBusiness(@PathVariable Integer id){
        clueService.clueToBusiness(id);
        return Result.success();
    }

//    伪线索
    @PutMapping("/false/{id}")
    public Result toFalseClue(@PathVariable Integer id ,@RequestBody ClueToFalsyDTO clueToFalsyDTO){
        clueService.toFalseClue( id,clueToFalsyDTO);
        return Result.success();
    }

//    线索池分页查询
    @GetMapping("/pool")
    public Result selectPoolByPage( ClueSelectPoolByPageDTO clueDTO){
        return Result.success(clueService.selectPoolByPage(clueDTO));
    }
}
